package com.juneng.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.juneng.common.Condition;
import com.juneng.utils.BeanCopyUtils;
import com.juneng.entity.CourseSection;
import com.juneng.mapper.CourseSectionMapper;
import com.juneng.service.ICourseSectionService;
import com.juneng.dto.CourseSectionDto;
import com.juneng.dto.CourseSectionQueryDto;
import com.juneng.utils.Uploadutil;
import com.juneng.vo.CourseSectionVo;
import org.springframework.stereotype.Service;
import lombok.AllArgsConstructor;
import java.util.List;
/**
 * 课程章节 服务实现类
 *
 * @author zds
 * @since 2021-07-08
 */
@Service
@AllArgsConstructor
public class CourseSectionServiceImpl implements ICourseSectionService {

    protected CourseSectionMapper courseSectionMapper;
    @Override
    public IPage<CourseSectionVo> page(CourseSectionQueryDto dto) {
        IPage<CourseSectionVo> page = Condition.getPage(dto);
        return courseSectionMapper.page(page,dto);
    }

    @Override
    public List<CourseSection> list(CourseSectionQueryDto dto) {
        QueryWrapper<CourseSection> queryWrapper = new QueryWrapper<>(BeanCopyUtils.copy(dto,CourseSection.class));
        return courseSectionMapper.selectList(queryWrapper);
    }

    @Override
    public Integer save(CourseSectionDto dto) {
        return courseSectionMapper.insert(BeanCopyUtils.copy(dto,CourseSection.class));
    }

    @Override
    public Integer updateById(CourseSectionDto dto) {
        return courseSectionMapper.updateById(BeanCopyUtils.copy(dto,CourseSection.class));
    }

    @Override
    public Integer deleteLogic(List<Integer> toIntList) {
        return courseSectionMapper.deleteBatchIds(toIntList);
    }

    @Override
    public CourseSection getById(Integer id) {
        return courseSectionMapper.selectById(id);
    }

    /**
     * 视频上传
     * @return
     */
    @Override
    public Integer addCourseSection() {
        return null;
    }
}
